package com.dduggs.img;


import java.util.Map;


import com.dduggs.service.CommonFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;


/**
 * Created by wangxy on 2017/12/12.
 * <p>
 * 文件上载
 * </p>
 */
@Controller
@RequestMapping("/file")
public class FileUploadResource {

    @Autowired
    private CommonFileService commonFileService;

    /**
     * 给图片及PDF文件增加水印并上传七牛
     * @throws Exception
     */
    @Transactional
	@ResponseBody
	@RequestMapping(value = "/addWatermark", method = RequestMethod.POST)
	public Map<String, String> upload(@RequestParam(value = "file") MultipartFile file) throws Exception{

		return commonFileService.upload(file);
	}
    
}
